import java.math.BigDecimal;
import java.util.Random;

import faction.xuanzhe.XunanzheExample;

public class JMain {
    public static void main(String[] args) {
    
    }
}
 class RSI6Calculator {

    public static double calculateRSI6(double[] prices) {
        double gainSum = 0;
        double lossSum = 0;

        for (int i = 1; i < prices.length; i++) {
            double priceDiff = prices[i] - prices[i - 1];
            if (priceDiff >= 0) {
                gainSum += priceDiff;
            } else {
                lossSum += Math.abs(priceDiff);
            }
        }

        double avgGain = gainSum;
        double avgLoss = lossSum;

        double RS = avgGain / avgLoss;
        double RSI = 100 - (100 / (1 + RS));

        return RSI;
    }

    public static void main(String[] args) {
      Random random = new Random();
        // 显示 41.86 37。499
        double[] prices = {0.06,0.04,0.02,0.01,0.02,0.04,0.04};
        double rsi6 = calculateRSI6(prices);
        System.out.println("RSI6 value is: " + rsi6);
    }
}
